package com.gimi.cloud.jimi.manage.service.userInfo.Impl;

import com.gimi.cloud.jimi.common.utils.StringUtil;
import com.gimi.cloud.jimi.common.utils.oss.AliOSSUtil;
import com.gimi.cloud.jimi.dao.dao.userInfo.RdTdDao;
import com.gimi.cloud.jimi.dto.userInfo.RdTdDTO;
import com.gimi.cloud.jimi.entity.userInfo.RdTd;
import com.gimi.cloud.jimi.manage.service.userInfo.RdTdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RdTdServiceImpl implements RdTdService {
    @Autowired
    private RdTdDao rdTdDao;

    @Override
    public RdTdDTO getNewestTd(RdTdDTO param) {
        RdTd td = rdTdDao.getNewestTd(param.getUserId());
        if(td != null) {
            RdTdDTO tdDTO = new RdTdDTO();
            if(!StringUtil.isBlank(td.getReportData()) && !td.getGetdata().startsWith("{")) {
                td.setReportData(AliOSSUtil.getFileUrl(td.getReportData(), AliOSSUtil.getNoEffictDateByDay(1)));
            }
            return tdDTO;
        }
        return null;
    }
}
